#include <stdio.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <net/ethernet.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>

int ex_str(char in[])
{
    char *a_in = (char*)malloc(256);
    a_in = in;
    char *a_in1 = strtok(a_in,",");
    char *a_in2 = strtok(NULL,",");
    char *a_in3 = strtok(NULL,",");




    printf("a_in的内容为:%s,地址为:%p\n",a_in,a_in);
    printf("a_in1的内容为:%s,地址为:%p\n",a_in1,a_in1);
    printf("a_in2的内容为:%s,地址为:%p\n",a_in2,a_in2);
    printf("a_in3的内容为:%s,地址为:%p\n",a_in3,a_in3);
}



int main(int argc, char const *argv[])
{
    char a[] = "123.456.789,9999,1";

    //ex_str(a);

    char ex_str[256] = "";
    strcpy(ex_str,a);
    char *str1 = strtok(ex_str,".");
    char *str2 = strtok(NULL,".");
    char *str3 = strtok(NULL,".");
    char *str4 = strtok(ex_str,",");
    char *str5 = strtok(NULL,",");

    printf("str1的内容是:%s\n",str1);
    printf("str2的内容是:%s\n",str2);
    printf("str3的内容是:%s\n",str3);
    printf("str4的内容是:%s\n",str4);
    printf("str5的内容是:%s\n",str5);
    char ex_num[256] = "";
    sprintf(ex_num,"%s%s%s%s%s",str1,str2,str3,str4,str5);

    printf("str5的地址为:%p\n",str5);

    printf("ex_num内容为:%s\n",ex_num);
    printf("ex_num的长度为%ld\n",strlen(ex_num));

    // for (int i = 0; i < strlen(ex_num); i++)
    // {
    //     printf("ex_num[%d]的内容为:%c\n",i,ex_num[i]);

    //     // if (ex_num[i]<'0'||ex_num[i]>'9')
    //     // {
    //     //     printf("请按正确格式输入内容!格式:IP,端口,内容!\n");
    //     //     return -1;
    //     // }
    // }
    //char b[] = "abcdefg";
    // char *a1 = strtok(a,",");
    // char *a2 = strtok(NULL,",");
    // char *a3 = strtok(NULL,",");

    // char ex_num[] = "";
    // sprintf(ex_num,"%s%s%s%s",a1,a2,a3,a4);

    // printf("ex_num内容为:%s\n",ex_num);

    // printf("a的内容为:%s,地址为:%p\n",a,a);
    // printf("a1的内容为:%s,地址为:%p\n",a1,a1);
    // printf("a2的内容为:%s,地址为:%p\n",a2,a2);
    // printf("a3的内容为:%s,地址为:%p\n",a3,a3);
    // printf("a4的内容为:%s,地址为:%p\n",a4,a4);
    




    return 0;
}
